/*
 * Copyright (c) 2005, 2014 vacoor
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 */
package org.vacoor.nothing.misc.express.usps.api.address;

import org.vacoor.nothing.misc.express.usps.api.data.UspsZipCode;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;

/**
 * <CityStateLookupResponse>
 * <ZipCode ID="0">
 * <Zip5>90210</Zip5>
 * <City>BEVERLY HILLS</City>
 * <State>CA</State>
 * </ZipCode>
 * <ZipCode ID="1">
 * <Zip5>20770</Zip5>
 * <City>GREENBELT</City>
 * <State>MD</State>
 * </ZipCode>
 * </CityStateLookupResponse>
 *
 * @author vacoor
 */
@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(name = "CityStateLookupResponse")
public class CSLResponse implements Iterable<UspsZipCode> {
    @XmlElement(name = "ZipCode")
    private List<UspsZipCode> zipCodes;

    public List<UspsZipCode> getZipCodes() {
        return zipCodes;
    }

    public void setZipCodes(List<UspsZipCode> zipCodes) {
        this.zipCodes = zipCodes;
    }

    @Override
    public Iterator<UspsZipCode> iterator() {
        return null != zipCodes ? zipCodes.iterator() : Collections.<UspsZipCode>emptySet().iterator();
    }
}
